/* 牛顿法计算平方根 */
#include <stdio.h>
#include <math.h>
#define PRRCISE 0.00001
int main(void)
{
    double x, y = 1.0, y0;
    printf("Enter a positive number: ");
    scanf("%lf", &x);
    for (;;) {
        y0 = (y + x / y) / 2.0;
        if (fabs(y - y0) < PRRCISE)
            break;
        y = y0;
    }
    printf("Square root: %.5lf\n", y0);
    return 0;
}